const commonUtil = require('../../util/common');

module.exports = (componentName = '') => {
  // 驼峰组件名
  const H_T_C_N = commonUtil.upperFirst(componentName);

  return `
import { defHttp } from '/@/utils/http/axios';
import { ${H_T_C_N}Item } from './model'

enum Api {
  Get${H_T_C_N}List = '/admin/${componentName}',
  Update${H_T_C_N} = '/admin/${componentName}/update',
  Del${H_T_C_N} = '/admin/${componentName}/del',
  Add${H_T_C_N} = '/admin/${componentName}/store',
}

export function get${H_T_C_N}List(data) {
  return defHttp.post<${H_T_C_N}Item>({ url: Api.Get${H_T_C_N}List, data });
}

export const update${H_T_C_N} = (data) => defHttp.post<any>({ url: Api.Update${H_T_C_N}, data });
export const del${H_T_C_N} = (data) => defHttp.post<any>({ url: Api.Del${H_T_C_N}, data });
export const add${H_T_C_N} = (data) => defHttp.post<any>({ url: Api.Add${H_T_C_N}, data });

`;
};
